package geez.widget;

import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ToggleButton;

import static geez.widget.Geez.withStyle;

public class GToggleButton extends ToggleButton implements GClickable, GFocusable {

    public GToggleButton() {
    }

    public GToggleButton(Image upImage) {
        super(upImage);
    }

    @Deprecated
    public GToggleButton(Image upImage, ClickListener listener) {
        super(upImage, listener);
    }

    public GToggleButton(Image upImage, ClickHandler handler) {
        super(upImage, handler);
    }

    public GToggleButton(Image upImage, Image downImage) {
        super(upImage, downImage);
    }

    @Deprecated
    public GToggleButton(Image upImage, Image downImage, ClickListener listener) {
        super(upImage, downImage, listener);
    }

    public GToggleButton(Image upImage, Image downImage, ClickHandler handler) {
        super(upImage, downImage, handler);
    }

    public GToggleButton(String upText) {
        super(upText);
    }

    public GToggleButton(String upText, ClickListener listener) {
        super(upText, listener);
    }

    public GToggleButton(String upText, String downText) {
        super(upText, downText);
    }

    public GToggleButton id(String id) {
        Geez.withNameAndId(this, id);
        return this;
    }

    public GToggleButton css(String cssClass, String... optionalClasses) {
        withStyle(this, cssClass, optionalClasses);
        return this;
    }

    public GToggleButton enable() {
        setEnabled(true);
        return this;
    }

    public GToggleButton disable() {
        setEnabled(false);
        return this;
    }

    public GWidget show() {
        setVisible(true);
        return this;
    }

    public GWidget hide() {
        setVisible(false);
        return this;
    }

    public GToggleButton tabIndex(int index) {
        setTabIndex(index);
        return this;
    }

    public GToggleButton add(ClickHandler handler) {
        addClickHandler(handler);
        return this;
    }

    public GToggleButton focus() {
        setFocus(true);
        return this;
    }

    public GToggleButton add(FocusHandler handler) {
        addFocusHandler(handler);
        return this;
    }

    public GToggleButton add(BlurHandler handler) {
        addBlurHandler(handler);
        return this;
    }
}
